{extend name="public/base"}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/admin/css/news.css" media="all" />
<link rel="stylesheet" type="text/css" href="__STATIC__/uploadify/uploadify.css">
<style>
    .bank_logo img{
        width: 200px;
        height:200px;
        border-radius: 100%;
    }
</style>
{/block}


{block name="main"}
<body class="childrenBody">
<form class="layui-form" action="?" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">银行名称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="name" lay-verify="required" placeholder="请输入银行名称" value="{$data.name|default=''}">
        </div>
    </div>
    <div class="layui-form-item bank_logo">
        <label class="layui-form-label">银行图片</label>
        <div class="site-demo-upload">
            <img id="bank_image" src="__STATIC__/home/images/jx_beta.png">
            <input type="file" name="image" class="layui-upload-file image">
        </div>
    </div>
    <div class="layui-form-item bank_logo">
        <label class="layui-form-label">银行logo</label>
        <div class="site-demo-upload">
            <img id="bank_logo" src="__STATIC__/home/images/jx_beta.png">
            <input type="file" name="image" class="layui-upload-file logo">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="logo" value="{$data.logo|default=''}">
            <input type="hidden" name="image" value="{$data.image|default=''}">
            <input type="hidden" name="id" value="{$data.id|default=''}">
            <button class="layui-btn" lay-submit="" lay-filter="send_form">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}

{block name="javascript"}
<script>
    layui.use(['form', 'upload', 'jquery'], function(){  //如果只加载一个模块，可以不填数组。如：layui.use('form')

        var upload = layui.upload, $ = layui.jquery; //获取upload模块

        //实例化image上传控件
        upload({
            url: '{:url("base/upload_image", ["image_type" => 4])}'
            ,elem: '.image' //指定原始元素，默认直接查找class="layui-upload-file"
            ,success: function(data){
                if (data.code == 200) {
                    $("#bank_image").attr('src', data.data[0].host_path);
                    $("input[name='image']").val(data.data[0].thumb_path);
                }
            }
        });

        //实例化logo上传控件
        upload({
            url: '{:url("base/upload_image", ["image_type" => 4])}'
            ,elem: '.logo' //指定原始元素，默认直接查找class="layui-upload-file"
            ,success: function(data){
                if (data.code == 200) {
                    $("#bank_logo").attr('src', data.data[0].host_path);
                    $("input[name='logo']").val(data.data[0].thumb_path);
                }
            }
        })
    });
</script>
{/block}